/*!
 * \file frreport_body_l7_add_int.c
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 *
 * \version 3.0
 * \author geyh
 * \date 2016/03/31
 *
 */
#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"
#include "conntrack.h"
#include "frct_comm.h"
#include <frdb_cursor.h>
#include "frreport_comm.h"

#include "apmtest_comm.h"

static int __suite_init(void)
{

    return 0;
}

static int __suite_cleanup(void)
{

    return 0;
}


static void __case1(void)
{
    Frreport_body_data *p_st_body_data=NULL;
    Conntrack *p_st_ct = NULL;
    char c_tmp = '\0';
    int i_ret = 0;

    p_st_ct = (Conntrack *)frmalloc(sizeof(Conntrack));
    memset(p_st_ct, 0x00, sizeof(Conntrack));
    p_st_ct->flg_direct_known = FR_DIRECT_KNOWN;
    p_st_ct->st_l7_analyzer.p_st_l7_module = (L7_module *)&c_tmp;

    p_st_body_data = frreport_body_new_l7(p_st_ct);

    i_ret = frreport_body_l7_add_int(p_st_body_data, "test", 1);

    CU_ASSERT_EQUAL(i_ret, FR_SUCC);

    frfree(p_st_ct);
    frreport_body_free(&p_st_body_data);

    return;
}


static void __case2(void)
{
    Frreport_body_data *p_st_body_data=NULL;
    Conntrack *p_st_ct = NULL;
    char c_tmp = '\0';
    int i_ret = 0;

    p_st_ct = (Conntrack *)frmalloc(sizeof(Conntrack));
    memset(p_st_ct, 0x00, sizeof(Conntrack));
    p_st_ct->flg_direct_known = FR_DIRECT_KNOWN;
    p_st_ct->st_l7_analyzer.p_st_l7_module = (L7_module *)&c_tmp;

    p_st_body_data = frreport_body_new_l7(p_st_ct);

    i_ret = frreport_body_l7_add_int(p_st_body_data, NULL, 1);

    CU_ASSERT_EQUAL(i_ret, FR_FAIL);

    frfree(p_st_ct);
    frreport_body_free(&p_st_body_data);

    return;
}

int add_suite_frreport_body_l7_add_int(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite("frreport_comm frreport_body_l7_add_int()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    CU_add_test(pSuite, "case1", __case1);
    CU_add_test(pSuite, "case2", __case2);

    return FR_SUCC;
}
